import types from './actionTypes'
import { fromJS } from "immutable";

const defaultState = fromJS({
  focus: false,
  mouseEnter: false,
  list: [],
  page: 1,
  totalPage: 1
});

export default (state = defaultState, action) => {
  switch (action.type) {
    case types.SEARCH_FOCUS:
      return state.set('focus', true)
    case types.SEARCH_BLUR:
      return state.set('focus', false)
    case types.CHANGE_LIST:
      return state.set('list', action.data).set('totalPage', action.totalPage)
    case types.MOUSE_ENTER:
      return state.set('mouseEnter', true)
    case types.MOUSE_LEAVE:
      return state.set('mouseEnter', false)
    case types.CHANGE_PAGE:
      return state.set('page', action.page)
    default:
      return state
  }
}
